package com.atguigu.day31.path02;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;

/*
 1.以后都使用绝对路径不要使用相对路径
 2.前端的绝对路径 /: http://localhost:8080/
    head 中可以写 base 标签 后续所有的资源都会拼接在base的后面
      <base href="/day31WEB_Web_exploded/">
 3.请求转发的绝对路径 / 应用名下
     http://localhost:8080/day31WEB_Web_exploded/

 4.重定向的 /
     http://localhost:8080/



 */
@WebServlet("/path")
public class PathServlet extends HttpServlet {

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {


        System.out.println("PathServlet 请求到达了");

        // /http://localhost:8080/day31WEB_Web_exploded/
       // req.getRequestDispatcher("/login.html").forward(req,resp);

        resp.sendRedirect("/day31_Web_exploded/login.html"); // http://localhost:8080/



    }
}
